const mongoose = require('mongoose')
const Schema = mongoose.Schema

const userSchema = mongoose.Schema({
  nickname: String,
  email: String,
  password: String,
  vip: {
    type: Schema.Types.ObjectId,
    ref: 'vip'
  },
  coin: {
    type: Number,
    default: 0,
  },
  sex: {
    type: String,
    default: '秘密'
  },
  avatar: {
    type: String, 
    default: ''
  },
  createAt: {
    type: Date,
    default: new Date()
  },
  movieCollection: [{
    type: Schema.Types.ObjectId,
    ref: 'movie'
  }],
  lastUpdate: {
    type: Date,
    default: new Date('2018-01-01')
  },
  lastOnline: {
    type: Date,
    default: new Date()
  },
  place: {
    type: String,
    default: '火星'
  }
})

module.exports = mongoose.model('user', userSchema)
